package com.markus.code.exam.duxiaoman;

import java.util.HashMap;
import java.util.Scanner;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/20 20:27
 * todo:
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            //小A手中的颜色
            String aStr = scanner.next();
            //需要涂的颜色
            String pStr = scanner.next();
            char[] aT = aStr.toCharArray();
            HashMap<Character,Integer> nodeMap = new HashMap<>();
            for (int i=0;i< aT.length;i++){
                if (nodeMap.containsKey(aT[i])){
                    nodeMap.put(aT[i],nodeMap.get(aT[i])+1);
                }else{
                    nodeMap.put(aT[i],1);
                }
            }
            char[] qT = pStr.toCharArray();
            System.out.println(process(qT,nodeMap));
        }
    }
    private static int process(char[] qT,HashMap<Character,Integer> nodeMap){
        int count = 0;
        for (int i=0;i<qT.length;i++){
            char temp = qT[i];
            if (!nodeMap.containsKey(temp)){
                continue;
            }
            count++;
            nodeMap.put(temp,nodeMap.get(temp)-1);
            if (nodeMap.get(temp) == 0){
                nodeMap.remove(temp);
            }
        }
        return count;
    }
}
